/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.socialfun.util;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.logging.Logger;

/**
 *
 * @author hp
 */
public class LookupBeanUtil {
    private static final Logger LOG = Logger.getLogger(LookupBeanUtil.class.getName());
    
    public static Object lookup(String nombreServicio) {
        try {
            InitialContext  iniCtx = new InitialContext();
            Context ejbCtx = (Context) iniCtx.lookup("java:global/SocialFun");
            LOG.info("ejbCtx.toString() = "+ ejbCtx.toString()); 
            LOG.info("ejbCtx.getNameInNamespace() = "+ ejbCtx.getNameInNamespace());
            LOG.info("ejbCtx.lookup = "+ ejbCtx.lookup(nombreServicio));
            return  ejbCtx.lookup(nombreServicio);
        } catch (NamingException ne) {
            LOG.error("Error al inyectar servicio " + nombreServicio + " Error: "+ ne);
            throw new RuntimeException(ne);
        }
    }
}
